package com.hdd.art.biz.show.controller;


import com.hdd.art.biz.show.dto.OpenScreensDo;
import com.hdd.art.biz.show.dto.ShowroomScreenDto;
import com.hdd.art.biz.show.dto.ShowroomScreenInfoDto;
import com.hdd.art.biz.show.dto.ShowroomScreenListDto;
import com.hdd.art.biz.show.entity.ShowroomScreen;
import com.hdd.art.biz.show.service.ShowroomScreenService;
import com.hdd.art.dto.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-07-05
 */
@RestController
@RequestMapping("/art-show/roomScreen")
@Api(value = "美术馆-展区封面",tags = {"美术馆-展区封面"})
public class ShowroomScreenController {

    @Autowired
    private ShowroomScreenService showroomScreenService;



    @PostMapping("/roomScreenList")
    @ApiOperation(value = "获取展区封面" ,notes = "")
    public AppResponse setDefaultOpenScreen(@Valid @RequestBody ShowroomScreenListDto screensDo ){
        AppResponse response = new AppResponse();
       response.setItems(showroomScreenService.list(screensDo.getArtId(),screensDo.getRoomId(),screensDo.getPageNo(),screensDo.getPageSize()));
        return response;
    }


    @PostMapping("/addRoomScreen")
    @ApiOperation(value = "展区封添加" ,notes = "")
    public AppResponse addRoomScreen(@Valid @RequestBody ShowroomScreenInfoDto screensDo ){
        AppResponse response = new AppResponse();
        ShowroomScreen showroomScreen = new ShowroomScreen();
        BeanUtils.copyProperties(screensDo,showroomScreen);
        showroomScreen.setDef("F");
        showroomScreenService.addShowRoomScreen(showroomScreen);
        return response;
    }


    @PostMapping("/delRoomScreen")
    @ApiOperation(value = "展区封面删除" ,notes = "")
    public AppResponse delRoomScreen(@Valid @RequestBody ShowroomScreenDto screensDo ){
        AppResponse response = new AppResponse();
        showroomScreenService.delShowRoomScreen(screensDo.getId());
        return response;
    }

    @PostMapping("/roomScreenInfo")
    @ApiOperation(value = "展区封面详情" ,notes = "")
    public AppResponse roomScreenInfo(@Valid @RequestBody ShowroomScreenDto screensDo ){
        AppResponse response = new AppResponse();
        response.setItem(showroomScreenService.findShowRoomScreen(screensDo.getId()));
        return response;
    }


}

